import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024 —03 —24
 * Time: 11:53
 */
public class Solution {

        public List<List<Integer>> generate (int numRows){
            List<List<Integer>> ret = new ArrayList<>();//
            List <Integer> list = new ArrayList<>();
            list.add(1);
            ret.add(list);
            for (int i = 1; i < numRows ; i++) {
                List <Integer>currentRow = new ArrayList<>();

                currentRow.add(1);

                List <Integer> prev = ret.get(i-1);
                for (int j = 1 ; j < i  ; j++) {
                    int  valu =prev.get(j-1)  + prev.get(j);
                    currentRow.add(valu);
                }
                currentRow.add(1);
                ret.add(currentRow);
            }
            return ret;
        }

    public static void main(String[] args) {
            Solution solution = new Solution();
        System.out.println(solution.generate(5));

    }
}
